<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // [js] 写一个判断设备来源的方法
    function checkPlatform() {
      // userAgent 属性是一个只读的字符串，声明了浏览器用于 HTTP 请求的用户代理头的值。
      let userAgentInfo = navigator.userAgent
      console.log(userAgentInfo);
      const Agents = ['Android', 'iPhone', 'SysbianOS', 'Windows Phone', 'iPad', 'iPod'];

      for (let i = 0; i < Agents.length; i++) {
        if (userAgentInfo.indexOf(Agents[i]) > 0) {
          console.log(12312, Agents[i]);
          return Agents[i]
        } else {
          console.log(1231, 'PC端');
          return
        }
      }
    }
    checkPlatform()


checkPlatform()
  </script>

</body>

</html>